//
//  ThirthViewController.m
//  UI_豆瓣app
//
//  Created by 151129-49宋强 on 15/12/23.
//  Copyright © 2015年 www.lanou3g.com蓝鸥. All rights reserved.
//

#import "ThirthViewController.h"
#import "cinemaModel.h"
#import "cinemaCell.h"

@interface ThirthViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong)UITableView *tableView;

@property (nonatomic, strong)NSMutableArray *dataArr;


@end

@implementation ThirthViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"影院";
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg_nav"] forBarMetrics:UIBarMetricsDefault];
    self.tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    
    
    [_tableView registerClass:[cinemaCell class] forCellReuseIdentifier:@"cell"];
    
    
    [self dataHandler];
    
}

- (void)dataHandler
{
    self.dataArr = [NSMutableArray array];
    NSArray *arr = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cinema" ofType:@"plist"] ];
    for (NSDictionary *dic in arr) {
        cinemaModel *m = [[cinemaModel alloc] init];
        [m setValuesForKeysWithDictionary:dic];
        [_dataArr addObject:m];
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    cinemaCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cinemaModel *m = _dataArr[indexPath.row];
    cell.label1.text = m.cinemaName;
    cell.label2.text = m.address;
    cell.label3.text = m.telephone;
    
    
    
    
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 200;
//    CGFloat h = [cinemaCell heightWithText:[_dataArr[indexPath.row] string]];
//    return h +20;
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
